//
//  BCOnlineStateView.m
//  BananaChat
//
//  Created by 于洪东 on 2019/11/2.
//  Copyright © 2019 香蕉. All rights reserved.
//

#import "BCOnlineStateView.h"

@interface BCOnlineStateView ()

@property (nonatomic,strong) UIView *dotView;
@property (nonatomic,strong) UILabel *tipsLabel;

@end

@implementation BCOnlineStateView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

-(void)setStates:(BCOnlineStates)states{
    if (states == BCOnlineStatesOnLine) {
        self.dotView.backgroundColor = [UIColor greenColor];
        self.tipsLabel.text = @"在线";
    }else if (states == BCOnlineStatesBusy){
        self.dotView.backgroundColor = [UIColor orangeColor];
        self.tipsLabel.text = @"繁忙";
    }else{
        
    }
}

-(void)setupUI{
    
    self.clipsToBounds = YES;
    self.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.2];
    
    [self addSubview:self.dotView];
    [self addSubview:self.tipsLabel];
    
    
    [self.dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(5);
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(10);
    }];
    self.dotView.layer.cornerRadius = 2.5;
    
    
    [self.tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.right.equalTo(self).offset(-10);
        make.width.mas_equalTo(50*ScaleX);
    }];
    
}

-(UIView *)dotView{
    if (_dotView == nil) {
        _dotView = [[UIView alloc]init];
    }
    return _dotView;
}

-(UILabel *)tipsLabel{
    if (_tipsLabel == nil) {
        _tipsLabel = [[UILabel alloc]init];
        _tipsLabel.textAlignment = NSTextAlignmentRight;
        _tipsLabel.font = [UIFont systemFontOfSize:14*ScaleX];
        _tipsLabel.textAlignment = NSTextAlignmentRight;
        _tipsLabel.textColor = [UIColor whiteColor];
    }
    return _tipsLabel;
}



@end


